package cn.t222.ch01.controller;

import cn.t222.ch01.mapper.UserMapper;
import cn.t222.ch01.pojo.User;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequiredArgsConstructor
public class HelloController {
    private final UserMapper userMapper;

    @GetMapping(value = {"","/hello"})
    public Object hello() {
        Map<String, Object> result = new HashMap<>();
        result.put("username", "张三");
        result.put("age", 18);
        return result;
    }

    @GetMapping("/users")
    public List<User> users() {
        return userMapper.getAll();
    }
}
